/*----------------------------------------------------------------------------
 * AllMenuView
 * ---------------------------------------------------------------------------
 * Date      : 2011-02-08
 * Author    : naiyumie
 * ---------------------------------------------------------------------------
 * USAGE
 * ---------------------------------------------------------------------------
 * $(selector).AllMenuView({'target':selector});
 * ---------------------------------------------------------------------------
 * EXAMPLE
 * ---------------------------------------------------------------------------
 *
 *----------------------------------------------------------------------------
 */
$.fn.AllMenuView	= function (option)
{
	var option		= option || {};
	var btn_close	= '<div class="btn-all-menu-close"><a href="#btn-menu-all" title="CLOSE"></a></div>';

	if ($(option.target).length<1) { return; }


	$(option.target).children('div.menu-all-wrap').hide().css({'overflow':'visible'}).each(function()
	{
		$(this).append(btn_close);

		var id	= $(this).attr('id');

		$(this).children('ul.menu-all-navigation').find('a').each(function()
		{
			var target	= $(this).attr('href');
			var	target_id	= target.split('#');
			var target_object	= $('div' + target);
			var is_target	= $(target_object).length>0 ? true : false;

			$(this).click(function()
			{
				if (id!=target_id[1] && is_target==true)
				{
					$(option.target).children('div.menu-all-wrap').hide();
					$(target_object).show();

					$(target_object).children('ul.menu-all-navigation').find('a').each(function()
					{
						if ($(this).attr('href')==target)
						{
							$(this).focus();
						}
					});
				}

				return false;
			});
		});
	});

	$(option.target).css({'position':'absolute', 'top':0, 'right':0, 'z-index':100, 'overflow':'visible', 'height':'auto'});

	$(this).click(function()
	{
		$('div#menu-all-view').show();

		if ($(option.target + ' div.menu-all-wrap:visible').length==0)
		{
			$(option.target + ' div.menu-all-wrap:first').show();
		}
		else
		{
			$(option.target).children('div.menu-all-wrap').hide();
		}

		return false;
	});

	$(option.target).find('div.btn-all-menu-close').click(function()
	{
		$(option.target).children('div.menu-all-wrap').hide();
		return false;
	});
};